package com.project.controller;


import com.Entity.DzmHisMedicinesEntity;
import com.Entity.DzmHisPurchaseEntity;
import com.Entity.DzmHisSupplierEntity;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;
import qsh.WeihuService;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(value={"*"},allowCredentials = "true")
public class WeihuController {
    @Reference
    private WeihuService wh;
/*查询*/
    @RequestMapping("/Findwh")
    public Object Findzssz(@RequestParam Map<String,Object> map){

      /*  System.out.println(map.get("medicines_name"+"medicines_class"));*/
        List<Map<String,Object>> ww = wh.xinxi(map);
        return ww;
    }
/*查询*/
    @RequestMapping("drcx")
    public Object all(@RequestParam Map<String,Object> map){
      // List<DzmHisMedicinesEntity> wq =wh.drcx();
        List<Map<String,Object>> wc = wh.drcx(map);
        return wc;
    }
/*s删除*/
    @RequestMapping("sc")
    public int delect(Integer medicines_id){
        int i= wh.delect(medicines_id);
        return i;
    }
/*导入*/
    @RequestMapping("dr")
    public int add(@RequestParam("arrays") List arrays){
       /* System.out.println(arrays+
        "..");*/
        wh.add(arrays);
        return 0;
    }

    /*供应商查询*/
    @RequestMapping("supplier")
    public Object gongyingshang(@RequestParam Map<String,Object> map){
        List<Map<String,Object>> wz = wh.supplier(map);
        return wz;
    }

    /*新增供应商*/
    @RequestMapping("gys")
    @ResponseBody
    public String addr(@RequestParam Map<String,Object> map){
      /* Collection<Object> aa = map.values();
        System.out.println(aa.toString());*/

      /* #{supplier_name},#{address},#{contact_name},#{contact_mobile},#{contact_telephone},#{bank_account}*/
       /* System.out.println(map.get("supplier_name"));
        System.out.println(map.get("address"));
        System.out.println(map.get("contact_name"));
        System.out.println(map.get("contact_mobile"));
        System.out.println(map.get("contact_telephone"));
        System.out.println(map.get("bank_account"));*/
       wh.gysadd(map);


      /*  System.out.println(map.get("supplier_name"));*/
        return "yes";
    }

    /*s删除*/
    @RequestMapping("suppsc")
    public int delectsup(Integer sid){
        int i= wh.delectsupp(sid);
        return i;
    }

    /*修改准备*/
    @RequestMapping("ready")
    public Object ready(@RequestParam Map<String,Object> map){
        List<Map<String,Object>> wq = wh.ready(map);
        return wq;
    }

    /*修改供应商*/
    @RequestMapping("update")
    @ResponseBody
    public String update(@RequestParam Map<String,Object> map) {

        wh.updete(map);
        return "yes";
    }

    /*采购入库*/
    /*添加药品的查询*/
    @RequestMapping("/yaopin")
    public Object yaopin(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> qw = wh.yaopin(map);
        return qw;
    }

    /*库存查询*/
    /*总库存查询*/
    @RequestMapping("/kucun")
    public Object kucun(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> op = wh.kucun(map);
        return op;
    }

    /*修改准备*/
    @RequestMapping("zhunb")
    public Object zhunb(@RequestParam Map<String,Object> map){
        List<Map<String,Object>> dp = wh.zhunb(map);
        return dp;
    }

    /*修改*/
    @RequestMapping("updateid")
    @ResponseBody
    public String updateid(@RequestParam Map<String,Object> map) {

        wh.updateid(map);
        return "yes";
    }

    /*添加*/
    @RequestMapping("tianjia")
    public List xinzhen(@RequestParam("str") List str){
/*
        System.out.println(str.size());
*/
       /* System.out.println(str);*/
        return wh.tianjia(str);
    }
    /*提交审核*/
    @RequestMapping("Purchaseadd")
    public Object Purchaseadd(HttpServletRequest request,@RequestBody List<Map<String,Object>> params){
     int a = wh.Purchaseadd(params);
        System.out.println(params);
        return a;
    }

    /*新增批次库存表*/
    @RequestMapping("addin")
    @ResponseBody
    public Object addin(@RequestParam Map<String,Object> map){
                Object b = wh.addin(map);
        System.out.println(b);
        return b;
    }

    /*直接入库*/
    @RequestMapping("Stockadd")
    public Object Stockadd(HttpServletRequest request,@RequestBody  List<Map<String,Object>> Stock){

        int st = wh.Stockadd(Stock);
        System.out.println();

        return st;
    }

    /*查询供应商*/
    @RequestMapping("gongys")
    public Object gongys(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> cl = wh.gongys(map);
        return cl;
    }

    /*查询批次库存表*/
    @RequestMapping("Toexamine")
    public Object Toexamine(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> cc = wh.Toexamine(map);
        return cc;
    }

    /*查询批次库存表*/
    @RequestMapping("seequery")
    public Object seequery(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> cm = wh.seequery(map);
        return cm;
    }

    /*查询具体单号*/
    @RequestMapping("oddnumbers")
    public Object oddnumbers(@RequestParam Map<String,Object> map){

        List<Map<String,Object>> cd = wh.oddnumbers(map);
        System.out.println(cd);
        return cd;
    }

    /*s删除*/
    @RequestMapping("delectcg")
    public int delectcg(Integer purchase_id){
        int i= wh.delectcg(purchase_id);
        return i;
    }

    /*修改状态*/
    @RequestMapping("updatestate")
    public String updatestate(Map map){
         wh.updatestate(map);
        return "yes";
    }
}
